﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace FlowersStore
{
	public partial class AdminOrders : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{

		}

		protected void ddlStatus_SelectedIndexChanged(object sender, EventArgs e)
		{
			switch (ddlStatus.SelectedValue)
			{
 				case "0":
					OrdersSqlDataSource.SelectCommand = "SELECT [Order].*,OrderStatus_name FROM [Order] join OrderStatus on [Order].OrderStatus_id=OrderStatus.OrderStatus_id order by case when [Order].OrderStatus_id=2 then 0 when [Order].OrderStatus_id=1 then 1 else 2 end asc,Order_DT desc";
					ListView1.DataBind();
					break;
				case "1":
					OrdersSqlDataSource.SelectCommand = "SELECT [Order].*,OrderStatus_name FROM [Order] join OrderStatus on [Order].OrderStatus_id=OrderStatus.OrderStatus_id where [Order].OrderStatus_id in (1,2) order by [Order].OrderStatus_id desc,Order_DT desc";
					ListView1.DataBind();
					break;
			}
		}

		protected string GetStatusImageUrl(object statusId)
		{
			long status = long.Parse(statusId.ToString());
			string statusImgUrl = "";
			switch (status)
			{
 				case 0:
					statusImgUrl = "~/Styles/Images/Done.png";
					break;
				case 1:
					statusImgUrl = "~/Styles/Images/InProgress.png";
					break;
				case 2:
					statusImgUrl = "~/Styles/Images/new.png";
					break;
				case 3:
					statusImgUrl = "~/Styles/Images/Denied.png";
					break;
				case 4:
					statusImgUrl = "~/Styles/Images/cancel.png";
					break;
			}
			return statusImgUrl;
		}
	}
}